<!DOCTYPE html>
<html lang="zh-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}{{ title }}{% endblock %}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        .sidebar {
            min-height: 100vh;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .sidebar .nav-link {
            color: rgba(255,255,255,0.8);
            padding: 12px 20px;
            margin: 2px 0;
            border-radius: 8px;
            transition: all 0.3s;
        }
        .sidebar .nav-link:hover, .sidebar .nav-link.active {
            color: white;
            background: rgba(255,255,255,0.1);
            transform: translateX(5px);
        }
        .main-content {
            background: #f8f9fa;
            min-height: 100vh;
        }
        .card {
            border: none;
            border-radius: 15px;
            box-shadow: 0 0 20px rgba(0,0,0,0.1);
        }
        .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border: none;
            border-radius: 25px;
        }
        .table {
            background: white;
            border-radius: 10px;
            overflow: hidden;
        }
        .table thead th {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            font-weight: 500;
        }
        .badge {
            border-radius: 15px;
        }
        .search-box {
            border-radius: 25px;
            border: 2px solid #e9ecef;
            transition: all 0.3s;
        }
        .search-box:focus {
            border-color: #667eea;
            box-shadow: 0 0 10px rgba(102, 126, 234, 0.2);
        }
    </style>
</head>
<body>
    <div class="container-fluid">
        <div class="row">
            <!-- 侧边栏 -->
            <div class="col-md-2 p-0">
                <div class="sidebar p-3">
                    <div class="text-center mb-4">
                        <h4 class="text-white">
                            <i class="fas fa-shopping-cart me-2"></i>
                            电商管理后台
                        </h4>
                    </div>
                    
                    <nav class="nav flex-column">
                        <a class="nav-link {% if request.resolver_match.url_name == 'custom_admin_dashboard' %}active{% endif %}" 
                           href="{% url 'custom_admin_dashboard' %}">
                            <i class="fas fa-tachometer-alt me-2"></i> 仪表板
                        </a>
                        <a class="nav-link {% if request.resolver_match.url_name == 'custom_admin_products' %}active{% endif %}" 
                           href="{% url 'custom_admin_products' %}">
                            <i class="fas fa-box me-2"></i> 产品管理
                        </a>
                        <a class="nav-link {% if request.resolver_match.url_name == 'custom_admin_comments' %}active{% endif %}" 
                           href="{% url 'custom_admin_comments' %}">
                            <i class="fas fa-comments me-2"></i> 评论管理
                        </a>
                        <a class="nav-link {% if request.resolver_match.url_name == 'custom_admin_rates' %}active{% endif %}" 
                           href="{% url 'custom_admin_rates' %}">
                            <i class="fas fa-star me-2"></i> 评分管理
                        </a>
                        <a class="nav-link {% if request.resolver_match.url_name == 'custom_admin_tags' %}active{% endif %}" 
                           href="{% url 'custom_admin_tags' %}">
                            <i class="fas fa-tags me-2"></i> 标签管理
                        </a>
                        <a class="nav-link {% if request.resolver_match.url_name == 'custom_admin_users' %}active{% endif %}" 
                           href="{% url 'custom_admin_users' %}">
                            <i class="fas fa-users me-2"></i> 用户管理
                        </a>
                        <hr class="my-3" style="border-color: rgba(255,255,255,0.2);">
                        <a class="nav-link" href="{% url 'index' %}" target="_blank">
                            <i class="fas fa-external-link-alt me-2"></i> 前台页面
                        </a>
                        <a class="nav-link" href="/admin/logout/">
                            <i class="fas fa-sign-out-alt me-2"></i> 退出登录
                        </a>
                    </nav>
                </div>
            </div>
            
            <!-- 主内容区 -->
            <div class="col-md-10 main-content p-4">
                <div class="d-flex justify-content-between align-items-center mb-4">
                    <h2>{% block page_title %}{{ title }}{% endblock %}</h2>
                    <div class="text-muted">
                        <i class="fas fa-user me-1"></i> {{ user.username }}
                        <span class="badge bg-success ms-2">在线</span>
                    </div>
                </div>
                
                {% if messages %}
                    {% for message in messages %}
                        <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
                            {{ message }}
                            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                        </div>
                    {% endfor %}
                {% endif %}
                
                {% block content %}
                {% endblock %}
            </div>
        </div>
    </div>
    
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    
    {% block extra_js %}
    {% endblock %}
</body>
</html>